<!-- 公告列表页 -->
<template>
	<view>
		<view class="empty" v-if="empty_show">
			<image :src="$IMG_URL+'empty.png'" mode=""></image>
			暂无公告哦~
		</view>
		<view class="message-box" v-for="(item,index) in messagelist" :key="index" v-else>
			<view class="content">
				{{item.desc}}
			</view>
			<view class="time">
				{{item.createtime}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: "1",
				messagelist: [],
				empty_show: false
			}
		},
		onLoad() {
			this.noticelists();
		},
		methods: {
			//下拉加载
			onPullDownRefresh() {
				this.messagelist = [];
				this.page = "1";
				this.noticelists();
				setTimeout(function() {
					uni.stopPullDownRefresh();
				}, 1000);
			},
			// 获取公告列表
			noticelists() {
				let that = this;
				that.$myRequest({
					url: 'addons/track/notice/lists', //请求地址
					method: 'GET', //请求方式
					data: {
						page: that.page
					} //请求参数
				}).then(res => {
					that.messagelist = that.messagelist.concat(res.data.data.data);
					if (that.messagelist == "") {
						that.empty_show = true;
					}
				})
			},
			onReachBottom() {
				let that = this;
				if (that.page >= "1") {
					that.page++;
					that.noticelists();
				}
			}
		}
	}
</script>
<style lang="scss" scoped>
	.empty {
		width: 100%;
		text-align: center;
		color: #666666;
		font-size: 30rpx;
	
		image {
			width: 70%;
			height: 360rpx;
			margin: 150rpx auto 0;
			display: block;
		}
	}
	.message-box {
		width: 92%;
		margin: auto;
		padding: 32rpx 4%;
		border-bottom: 2rpx solid #F9F9F9;

		.content {
			font-size: 32rpx;
			color: #333333;
		}

		.time {
			font-size: 22rpx;
			color: #999999;
			margin-top: 16rpx;
		}
	}
</style>
